<?php
//------------------------
// 商品管理验证器
//-------------------------

namespace app\common\validate;

use think\Validate;

class Goods extends Validate
{
    protected $rule = [
        // 基础信息
        'goods_name|商品名称'     => 'require|max:256|unique:goods',
        'cate_id|分类'            => 'require|number',
        'brand_id|品牌'           => 'number',
        'goods_sn|货号'           => 'max:64',
        'now_price|现价格'        => 'require|float',
        'original_price|原价格'   => 'float',
        'promote_price|促销价格'  => 'float',
        'goods_brief|简介'        => 'max:256',
        'status|状态'             => 'number',
        // 详细信息
        'goods_content|商品详细信息'        => 'require',
        // 商品属性
        'type_id'          => 'require|number',
        // 其他信息
        'stock_qty|库存量'        => 'number',
        'goods_weight|重量'       => 'float',
        'meta_keywords|关键词'    => 'max:256',
        'meta_description|描述'   => 'max:256',

    ];

     protected $message  =   [
        'cate_id.require' => '请选择商品分类',
        'type_id.require' => '请选择商品类型',
    ];


    protected $scene = [
        'add'  => ['goods_name', 'cate_id','brand_id','goods_sn','now_price','original_price','promote_price','goods_brief','status'],
        'editBasics'  => ['goods_name', 'cate_id','brand_id','goods_sn','now_price','original_price','promote_price','goods_brief','status'],
        'editAlbum'  => ["meta_keywords"],
        'editDetails'  => ['goods_content'],
        'editGoodsAttr'  => ['type_id'],
        'editOther'  => ['stock_qty', 'goods_weight','meta_keywords','meta_description'],
    ];
}